import axios from 'axios'
import config from '@renderer/config'

//1. 创建axios对象
const request = axios.create({
  baseURL: config.api
})

//2. 请求拦截器
request.interceptors.request.use(
  function (config) {
    return config
  },
  function (error) {
    return Promise.reject(error)
  }
)

//3. 响应拦截器
request.interceptors.response.use(
  function (response) {
    return response.data
  },
  function (error) {
    return Promise.reject(error)
  }
)

export default request
